'use strict';

/**
 * Config for the router
 */
angular.module('app')
    .run(
    ['$rootScope', '$state', '$stateParams',
        function ($rootScope, $state, $stateParams) {
            $rootScope.$state = $state;
            $rootScope.$stateParams = $stateParams;
        }
    ]
)
    .config(
    ['$stateProvider', '$urlRouterProvider',
        function ($stateProvider, $urlRouterProvider) {

            $urlRouterProvider
                .otherwise('/app/home');
            $stateProvider
                .state('access', {
                    url: '/access',
                    template: '<div ui-view class="fade-in-right-big smooth"></div>'
                })
                .state('access.denied', {
                    url: '/denied',
                    templateUrl: 'tpl-common/denied/denied.html'
                })
                .state('access.login', {
                    url: '/login',
                    templateUrl: 'tpl-common/login/login.html',
                    resolve: {
                        deps: ['$ocLazyLoad',
                            function ($ocLazyLoad) {
                                return $ocLazyLoad.load(['tpl-common/login/login.js']);
                            }]
                    }
                })
                .state('app', {
                    abstract: true,
                    url: '/app',
                    templateUrl: 'tpl/app.html'
                })
                // 系统管理部分
                .state('app.home', {
                    url: '/home',
                    templateUrl: 'tpl-common/home.html'
                })
        }
    ]
);